<?php
namespace App\Modules\Admin\Services;

use App\Models\Admin\SysDict;

class DictService extends AdminService
{
    protected $model = SysDict::class;

    public function getQueryBuilder(Array $data)
    {
        $this->queryBuilder = SysDict::query();
        if(isset($data['name']) && strlen($data['name'] > 0)) {
            $this->queryBuilder->where('name', 'like', $data['name'].'%');
        }
        $this->queryBuilder->where('status', 1)->where('type_code', $data['type_code']);
    }

    public function options($codeType)
    {
        return SysDict::select('name', 'value')->where('type_code', $codeType)->where('status', 1)->get();
    }
}